let currentLang = 'zh-CN';

export const loadLocale = async (lang) => {
  const response = await fetch(`./locales/${lang}.json`);
  currentLang = lang;
  return response.json();
};

export const t = (key) => {
  const strings = require(`../locales/${currentLang}.json`);
  return key.split('.').reduce((o, i) => o[i], strings);
};